<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<title>订单列表-商城管理-{$site.BACK_NAME}</title>
<include file="Public:jscss"/>
</head>
<body>
<div class="wrap">
 <include file="Public:head"/>
 <div class="mainBody">
  <include file="Public:left"/>
  <div id="Right">
   <div class="Item hr">
    <div class="current">产品列表</div>
   </div>
   <form action="" method="post" id="quickForm">
	<b>分类：</b>&nbsp;
	<select name="act" style="width: 80px;">
	 <option value="-1">不限</option>
	 <option value="0" {:is_selected($act,0)}>未审核</option>
	 <option value="2" {:is_selected($act,2)}>已拒绝</option>
	 <option value="1" {:is_selected($act,1)}>已通过</option>
	</select>
    <b>快速搜索：</b>&nbsp;
    <input type="text" name="kwd" value="{$kwd}" placeholder="请输入关键字" class="input"/> &nbsp;
	<input type="submit" class="btn quickSubmit" value='搜索'/>
   </form>
   <form action="" method="post" id="tab_form">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
     <thead>
      <tr>
       <td width="20%">订单编号</td>
       <td width="10%">下单人</td>
       <td width="10%">总花费</td>
	   <td width="10%">收货人</td>
	   <td width="10%">收货人电话</td>
       <td width="10%">下单时间</td>
       <td width="20%">操作</td>
      </tr>
     </thead>
     <volist name="list" id="vo">
     <tr align="center" id="tr_{$vo.id}">
      <td>{$vo.order_sn}</td>
      <td align="left">{$vo.u_name}</td>
      <td align="left">{$vo.total_pay}</td>
	  <td align="left">{$vo.sh_name}</td>
	  <td align="left">{$vo.sh_mobile}</td>
	  <td>{$vo.add_time|date="Y-m-d H:i:s",###}</td>
      <td align="left">
	   [ <a href="{:U('Mall/detail',array('id'=>$vo['id']))}" target="_blank"> 详情 </a> ]
	   <switch name="vo.r_action">
	   <case value="1">
	   [ <font style="color:green;">{$vo.r_time|date="y-m-d",###}</font>通过 ]
	   </case>
	   <case value="2">
	   [ <font style="color:red;">{$vo.r_time|date="y-m-d",###}</font>拒绝 ]
	   </case>
	   <default/>
	   [ <a href="javascript:void(0)" data-id="{$vo['id']}" data-sn="{$vo.order_sn}" class="cfz_accept">通过 </a> ]&nbsp;&nbsp;&nbsp;
	   [ <a href="javascript:void(0)" data-id="{$vo['id']}" data-sn="{$vo.order_sn}" class="cfz_refuse">拒绝 </a> ]
	   </switch>
	  </td>
     </tr>
     </volist>
    </table>
   </form>
   <div class="viciao">{$pager}</div>
   <div class="commonBtnArea">
   </div>
  </div>
 </div>
</div>
<div class="clear"></div>
<include file="Public:foot"/>
</body>
<script type="text/javascript">
$(function(){
	//单个通过
	$(".cfz_accept").click(function(){
		var that = $(this);
		if(that.data("busy") == 1){
			$.jBox.tip('已提交，系统在处理中...', 'info');
			return false;
		}
		var order_id = that.data("id");
		$.jBox.confirm(
			'确定审核通过订单【<b>'+that.data("sn")+'</b>】吗?',
			"温馨提示",
			function(v, h, f) {
				if(v == 'ok'){
					that.data("busy",1);
					$.getJSON("{:U('Mall/accept')}", {id:order_id}, function(json){
						if(json.errcode==0){
							$.jBox.tip(json.errmsg, 'success');
							setTimeout(function(){
								location.href = "{:U('Mall/order')}";
							},2000);
						}else{
							$.jBox.tip(json.errmsg, 'error');
						}
					});
					$.jBox.tip("系统处理中，请稍候....", 'loading');
					return true;
				}
			}
		);	
	});
	//单个拒绝
	$(".cfz_refuse").click(function(){
		var that = $(this);
		if(that.data("busy") == 1){
			$.jBox.tip('已提交，系统在处理中...', 'info');
			return false;
		}
		var order_id = that.data("id");
		var t_html = "<div style='padding:10px;'><textarea class='input' style='height: 60px; width: 98%;' name='reason'></textarea></div>";
		$.jBox(t_html, {
			title: "请填写拒绝原因:",
			submit: function (v, h, f) {
				if (f.reason == '') {
					$.jBox.tip("请输入拒绝原因", 'error');
					return false;
				}
				that.data("busy",1);
				$.post("{:U('Mall/refuse')}", {'id' : order_id, 'reason' : h.find(":input[name='reason']").val()}, function(json){
					if(json.errcode==0){
						$.jBox.tip(json.errmsg, 'success');
						setTimeout(function(){
							self.location.reload(true);
						},2000);
					}else{
						$.jBox.tip(json.errmsg, 'error');
					}
				});
				$.jBox.tip("系统处理中，请稍候....", 'loading');
				return true;
			}
		});
	});
});
</script>
</html>